import cv2
cap = cv2.VideoCapture(0)
while cap.isOpened():
    retval, frame = cap.read()
    if not retval:
        print("没有视频")
        break
    cv2.imshow('video', frame)
    key = cv2.waitKey(120)
    if key == ord('w'):
        break
cap.release()
cv2.destroyAllWindows()